﻿<cfsilent>
	<cfscript>
		
		jsonAdvice = getProperty("serviceFactory").getBean("jsonAdvice");
		
		taskProp = getProperty("serviceFactory").getBean("taskPropertyAdvice");

		response = structNew();
		structInsert(response, "success", false, true);

		taskId = event.getArg("TSK");
		taskType = event.getArg("TT");
		
		transaction {
			
			/* 载入教学任务 */
			switch(taskType){

				case "P":
					sql = "	SELECT
								t.task_prop
							FROM
								t_task t
							WHERE
								t.tsk_id = :taskId ";
					break;	
				case "C":
					sql = "	SELECT
								t.task_prop
							FROM
								t_common_task t
							WHERE
								t.tsk_id = :taskId ";
					break;	
				case "R":
					sql = "	SELECT
								t.task_prop
							FROM
								t_reopen_task t
							WHERE
								t.tsk_id = :taskId ";
					break;
				case "T":
					sql = "	SELECT
								t.task_prop
							FROM
								t_sport_task t
							WHERE
								t.tsk_id = :taskId ";
					break;	
			}
			
			queryObj = new Query(datasource = application.dnsMaster);
			queryObj.addParam(name = "taskId", value = taskId, cfsqltype = "cf_sql_varchar");
			rs_taskEntity = queryObj.execute(sql = sql).getResult();
			
			taskProp.parseProperty( rs_taskEntity.task_prop );
			
			/* 取消教学任务的撤班标志 */
			taskProp.setCancel( false ); /* 是否撤班 = 否 */
			
			switch(taskType){
				case "P":
					sql = "	UPDATE
								t_task t
							SET
								t.task_prop = :taskProp 
							WHERE
								t.tsk_id = :taskId ";
					break;
				case "C":
					sql = "	UPDATE
								t_common_task t
							SET
								t.task_prop = :taskProp 
							WHERE
								t.tsk_id = :taskId ";
					break;
				case "R":
					sql = "	UPDATE
								t_reopen_task t
							SET
								t.task_prop = :taskProp 
							WHERE
								t.tsk_id = :taskId ";
					break;
				case "T":
					sql = "	UPDATE
								t_sport_task t
							SET
								t.task_prop = :taskProp 
							WHERE
								t.tsk_id = :taskId ";
					break;
			}
			
			queryObj = new Query(datasource = application.dnsMaster);
			queryObj.addParam(name = "taskId", value = taskId, cfsqltype = "cf_sql_varchar");
			queryObj.addParam(name = "taskProp", value = taskProp.stringProperty(), cfsqltype = "cf_sql_varchar");
			queryObj.execute(sql = sql);
			
			structInsert(response, "success", true, true);
		}
				
	</cfscript>
</cfsilent><cfoutput>#jsonAdvice.encode(data:response, stringNumbers:true)#</cfoutput>